<template>
  <div class="user">
    <!-- 搜索条件 -->
    <el-form
      :inline="true"
      :model="userForm"
      class="demo-form-inline"
      size="small"
    >
      <el-form-item label="openId">
        <el-input v-model="userForm.openid"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="searchUser">查询</el-button>
      </el-form-item>
    </el-form>
    <!-- 用户列表 -->
    <div class="user-table">
      <el-table :data="userList" height="380" border>
        <el-table-column
          prop="openid"
          label="openId"
          width="260"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="name"
          label="用户昵称"
          width="230"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="contact"
          label="联系方式"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="drom" label="宿舍" width="120" align="center">
        </el-table-column>
        <el-table-column prop="gender" label="性别" width="120" align="center">
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import userApi from "@/api/user";
export default {
  data() {
    return {
      userForm: {
        openid: "",
      },
      userList: [],
    };
  },
  created() {
    this.getUserList();
  },
  methods: {
    //   获取用户列表
    async getUserList() {
      const res = await userApi.getUser();
      this.userList = res.data;
    },
    //   查询用户
    async searchUser() {
      const res = await userApi.searchUser(this.userForm);
      this.userList = res.data;
      console.log("submit!");
    },
  },
};
</script>

<style scoped lang="less">
.user {
  padding: 30px;
  .user-table {
    margin-top: 25px;
    margin-left: 10px;
  }
}
</style>